<template>
  <!-- 客户列表信息 -->
  <div>
    <!-- 内容 -->
    <div>
      <!-- 头部 -->
      <van-row class="header4" gutter="20">
        <van-col span="2">
          <van-icon name="arrow-left" @click="$router.go(-1)" />
        </van-col>
        <van-col span="18">
          <span>客户列表信息</span>
        </van-col>
        <van-col span="4">
          <span>新增</span>
        </van-col>
      </van-row>
      <!-- 搜索框 -->
      <van-search
        v-model="value"
        show-action
        shape="round"
        placeholder="客户名称/联系方式"
        @search="onSearch"
      >
        <template #action>
          <div class="fontsiz" @click="onSearch">搜索</div>
        </template>
      </van-search>
      <!-- 下方列表 -->
      <div class="describe" v-for="item in records" :key="item.id">
        <div class="xaing" @click="jump(item.id)">
          <dl>
            <dd>
              <p>
                <span>客户名称</span>
                <i>{{ item.custName }}</i>
              </p>
              <p>
                <span>联系方式</span>
                <i>{{ item.telephone }}</i>
              </p>
              <p>
                <span>公司名称</span>
                <i>{{ item.company }}</i>
              </p>
              <p>
                <span>职务</span>
                <i>{{ item.position ? item.position : "无" }}</i>
              </p>
            </dd>
          </dl>
        </div>
        <div class="btnbox">
          <van-button color="#003399" round type="primary" :block="false"
            >新增拜访</van-button
          >
          <van-button color="#003399" round type="primary" :block="false"
            >拜访记录</van-button
          >
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { GetCustList } from "@/request/api";
export default {
  props: ["block"],
  data() {
    return {
      value: "",
      loading: false,
      finished: false,
      records: []
    };
  },
  methods: {
    onSearch() {
      GetCustList({
        keyword :this.value
      }).then(res => {
        this.records = res.data.records;
      });
    },
    jump(id) {
      this.$router.push(`/UserListXiang?id=${id}`);
    }
  },
  created() {
    GetCustList().then(res => {
      this.records = res.data.records;
    });
  }
};
</script>
 
<style lang = "less" scoped>
.header4 {
  background-color: #003399;
  color: #fff;
  padding: 0.166667rem 0.066667rem;
  text-align: center;
  display: flex;

  .van-icon {
    font-size: 0.186667rem;
    vertical-align: -0.056667rem;
  }
}
.fontsiz {
  color: #003399;
}
.describe {
  background-color: #fff;
  margin-top: 0.133333rem;
  box-sizing: border-box;
  .p1 {
    line-height: 0.32rem;
    padding: 0.066667rem;
    margin: 0;
  }
  .van-icon {
    margin: 0.15667rem;
  }
}
.xaing {
  border-bottom: 1px solid #eee;
  border-top: 1px solid #eee;
  dl {
    dt {
      width: 20%;
      padding: 0 0.066667rem;
      box-sizing: border-box;
      img {
        width: 100%;
      }
    }
    dd {
      margin: 0.066667rem;
      p {
        margin: 0.036667rem;
        i {
          font-weight: 600;
          margin-left: 0.126667rem;
        }
      }
      .p2 {
        font-weight: 600;
      }
    }
  }
}
.van-button {
  width: 1.066667rem;
  margin: 0.106667rem;
}
.btnbox {
  margin-left: 1.566667rem;
}
</style>